package com.mycompany.j2eem.controller;

import com.mycompany.j2eem.Entity.JsonResult;
import com.mycompany.j2eem.Entity.ResultCode;
import com.mycompany.j2eem.Entity.Test;
import com.mycompany.j2eem.Mapper.wcymapper.LoginMapper;
import com.mycompany.j2eem.Mapper.wcymapper.PersonalHubMapper;
import com.mycompany.j2eem.service.wrjservice.ModelService;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class testController {

    @Autowired
    ModelService modelService;

    @Autowired
    PersonalHubMapper personalHubController;

    @Autowired
    LoginMapper loginMapper;

    //测试是否能够前后连通
    @RequestMapping("/test")
    public JsonResult test(HttpSession session) {
        session.setAttribute("username", "15161607893");
        return new JsonResult(ResultCode.SUCCESS, session.getId());
    }

    @RequestMapping("/anothertest")
    public JsonResult test2(HttpSession session) {

        return new JsonResult(ResultCode.SUCCESS, session.getAttribute("username"));
    }

    @RequestMapping("/testModel")
    public JsonResult testModel() {
        Float a = modelService.rebackParam("SSS", "sss");
        return new JsonResult(ResultCode.SUCCESS, a);
    }

    @RequestMapping("/hello")
    public String test() {
        String temp = loginMapper.testnull();
        if (temp == null) {
            return "空";
        }
        return "不空";
    }

    @RequestMapping("/testlist")
    public List<String> testlist(@RequestParam("list") List<String> a) {
        return a;
    }

    @RequestMapping("/testFile")
    public JsonResult doUpLoadToPersonal(@RequestParam("Images") MultipartFile file) {
        return new JsonResult(ResultCode.SUCCESS, file.getSize());
    }


}
